import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseRouter/YBNavigator.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBColor/YBColor.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBNetWorkModule/YBWorkTaiNetWork/YBBaseWorkTaiNetWorkManager.dart';

class YBQuestionFeakBackPage extends StatefulWidget {

  final String requestCodeStr;
  final String sysCode;

  const YBQuestionFeakBackPage({Key key, this.requestCodeStr, this.sysCode}) : super(key: key);

  @override
  _YBQuestionFeakBackPageState createState() => _YBQuestionFeakBackPageState(sysCode: sysCode,requestCodeStr: requestCodeStr);
}

class _YBQuestionFeakBackPageState extends State<YBQuestionFeakBackPage> {

  String _dateTimeStr = YBChineseText.workTaiLianXiTimeTitle;

  TextEditingController _editingController = TextEditingController();

  final String requestCodeStr;
  final String sysCode;

  _YBQuestionFeakBackPageState({this.requestCodeStr, this.sysCode});

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Scaffold(
        appBar:AppBar(
          title: Text(YBChineseText.workTaiFanKuiYiYiTitle,style: YBTextStyle.TextStyle30313320Medium),
          elevation: 0,
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Expanded(
              child:SingleChildScrollView(
                child: Padding(
                  padding:EdgeInsets.fromLTRB(YBTextStyle.adapterSize20, YBTextStyle.adapterSize20, YBTextStyle.adapterSize20, 0),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: [
                      Container(
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.all(Radius.circular(YBTextStyle.adapterSize8)),
                          border: Border.all(color: YBColor.color999999,width: 0.5),
                        ),
                        child: Padding(
                          padding: EdgeInsets.fromLTRB(YBTextStyle.adapterSize10, 0, YBTextStyle.adapterSize10, 0),
                          child: TextField(
                            decoration:InputDecoration(
                              hintText: YBChineseText.workTaiYiYiZhuangTaiTitle,
                              border: InputBorder.none,
                            ),
                            controller: _editingController,
                          ),
                        ),
                      ),
                      Container(
                        height: YBTextStyle.adapterSize15,
                      ),
                      Container(
                        decoration: BoxDecoration(
                           borderRadius: BorderRadius.all(Radius.circular(YBTextStyle.adapterSize8)),
                           border: Border.all(color: YBColor.color999999,width: 0.5),
                        ),
                        child: InkWell(
                          child: Padding(
                            padding:EdgeInsets.only(left:YBTextStyle.adapterSize10,right:YBTextStyle.adapterSize10,top: YBTextStyle.adapterSize15,bottom:  YBTextStyle.adapterSize15),
                            child: Text(
                              _dateTimeStr??YBChineseText.workTaiLianXiTimeTitle,
                              style: TextStyle(
                                color: YBColor.color999999,
                                fontSize: YBTextStyle.adapterSize16,
                                fontWeight: FontWeight.w300,
                              ),
                            ),
                          ),
                          onTap: () async {
                            DatePicker.showDateTimePicker(context,showTitleActions: true,maxTime: DateTime.now(),locale: LocaleType.zh,onChanged: (date){
                              print("-------${date}--");
                            },onConfirm: (date){
                              print("-------${date}--");
                              _dateTimeStr = date.toString();
                              setState(() {

                              });
                            });
                          },
                        ),
                      ),
                      Container(
                        height: YBTextStyle.adapterSize15,
                      ),
                      Container(
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.all(Radius.circular(YBTextStyle.adapterSize8)),
                          border: Border.all(color: YBColor.color999999,width: 0.5),
                        ),
                        child: TextField(
                          maxLines: 6,
                          decoration: InputDecoration(
                            border:InputBorder.none,
                            hintText:YBChineseText.workTaiBeizhuTitle,
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ),
            Container(
              height: YBTextStyle.adapterSize64,
              child: Padding(
                padding: EdgeInsets.fromLTRB(YBTextStyle.adapterSize20, YBTextStyle.adapterSize10, YBTextStyle.adapterSize20, YBTextStyle.adapterSize10),
                child: FlatButton(
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.all(Radius.circular(YBTextStyle.adapterSize8)),
                  ),
                  color: YBColor.commonThemeColor,
                  child: Text(
                    YBChineseText.enterTiJiaoTitle,
                    style: TextStyle(
                      color: YBColor.white,
                      fontWeight: FontWeight.w500,
                      fontSize: YBTextStyle.adapterSize16,
                    ),
                  ),
                  onPressed: () async {
                     _setYiYinInfo();
                  },
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
  
  void _setYiYinInfo(){
    YBBaseWorkTaiNetWork.workTaiYiYiFeedbackInfo({
     "requestCode":requestCodeStr,
      "sysCode":sysCode,
      "dissentGenerateTime":_dateTimeStr,
      "dissentDesc":_editingController.text,
    },success: (data){
      print("--结果---$data--");
      var dataBool = data;
      if (dataBool is bool) {
        EasyLoading.showSuccess("反馈成功");
        YBNavigatorUtil.goDefaultBack(context);
      }
    });
  }
  
}
